package com.apes.fico.engine.timerTask;

import com.apes.fico.engine.model.ReduceVoucher;
import com.apes.fico.engine.model.TempVoucher;
import com.apes.fico.masterdata.gl.model.AccountingModel;
import com.apes.framework.api.SpringManager;
import org.springframework.stereotype.Service;


/*
*  按单直接归约
* */
@Service
public class ReduceToGLVoucherImpl implements Reduce {

    @Override
    public boolean correctCycle(String cycle) {
        return AccountingModel.RT.equals(cycle);
    }

    @Override
    public void reduce(TempVoucher tempVoucher) {
        ReduceVoucher reduceVoucher = BasisService.toReduceVoucher(tempVoucher,null,null);
        // 新增财务凭证并审核
        SpringManager.getBean(BasisService.class).createGLVoucherAndApprove(reduceVoucher);
        // 更新原始凭证归集状态
        BasisService.updateTempVoucherState(tempVoucher);
    }




}
